<template>
	<view :style="style">
		<!-- 状态栏占位 -->
		<view :style="statusStyle"></view>
		<!-- 导航栏: 没传入title，完全由上层自已实现 -->
		<slot v-if="!title" name="nav"></slot>
		<!-- 导航栏: 有传入title，完全由上层自已实现 -->
		<view v-else class="head-menu">
			<view v-if="showBack" class='iconfont icon-xiangzuo' @click="goBack"></view>
			<!-- <view v-if="showHome" class="iconfont icon-shouye4" @click="goHome"></view> -->
			<view class="pd-l-md text-lg">{{title}}</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"MyCustomNav",
		data() {
			return {
				
			};
		},
		computed: {
			style() {
				return `background-color: ${this.bgColor}; color:white;`;
			},
			
			// 状态栏
			statusStyle() {
				const {
					statusBarHeight = 20
				} = uni.getSystemInfoSync();
				return `width:100%; height: ${statusBarHeight+5}px`;
			}
		},
		props: {
			bgColor: {
				type: String,
				default: ''
			},
			title: {
				type: String,
				default: ''
			},
			showBack: {
				type: Number,
				default: 1,
			},
			// showHome: {
			// 	type: Number,
			// 	default: 0,
			// }
			// customNavType: {
			// 	type: Number,
			// 	default: 0, // 0-完全由上层自已实现，1-上层只需要传入title
			// },
		},
		methods: {
			goBack() {
				uni.navigateBack();
			},
			goHome() {
				uni.switchTab({
					url: '/pages/index/index'
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	@import "@/leui.scss";
	
	.head-menu {
		display: flex;
		align-items: center;
		height: 54rpx;
		// width: 140rpx;
		// background: rgba(0, 0, 0, .25);
		// border-radius: 27rpx;
		
		.iconfont {
			// flex: 1;
			text-align: center;
			color: #fff;
			box-sizing: border-box;
		}
	}
</style>
